//本地存储
interface Item{
  count:number
  time:string
}

const key = 'ts-key'

//本地存储-存
function setData(data:Item[]):void{
  localStorage.setItem(key,JSON.stringify(data))
}

//本地存储-取
function getData():Item[]{
  return JSON.parse(localStorage.getItem(key) || '[]')
}

//测试用的代码
// setData([{count:1,time:'18:00:00'}])
// const arr = getData()
// arr.forEach(item=>{
//   console.log(`刷新次数为${item.count},刷新时间为${item.time}`);
  
// })

function pageLoad(){
  const list = getData()
  const time = new Date().toTimeString().slice(0,8)
  const lestItem = list[list.length-1]
  if(lestItem){
    list.push({
      count:lestItem.count+1,
      time:time
    })
  }else{
    list.push({
      count:1,
      time:time
    })
  }
  setData(list)
}

pageLoad()